/*
 *  Copyright 2009 Rohan Ranade.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */
package org.netbeans.modules.cpextender.util;

import org.netbeans.api.java.project.classpath.ProjectClassPathModifier;
import org.netbeans.api.project.Project;
import org.netbeans.modules.cpextender.api.CPExtensionManager;
import org.netbeans.spi.project.AuxiliaryConfiguration;
import org.openide.util.Lookup;

/**
 *
 * @author Rohan Ranade
 */
public final class Utilities {

    private Utilities() {
    }

    public static Project getProject(Lookup context) {
        Project project = context.lookup(Project.class);
        if (project == null) {
            throw new IllegalStateException("The lookup " + context + " does not contain a Project");
        }
        return project;
    }

    public static CPExtensionManager getCPExtensionManager(Project project) {
        CPExtensionManager manager = project.getLookup().lookup(CPExtensionManager.class);
        assert manager != null;
        return manager;
    }

    public static ProjectClassPathModifier getClassPathModifier(Project project) {
        ProjectClassPathModifier modifier = project.getLookup().lookup(ProjectClassPathModifier.class);
        assert modifier != null;
        return modifier;
    }
    
    public static AuxiliaryConfiguration getAuxiliaryConfiguration(Project project) {
        AuxiliaryConfiguration aux = project.getLookup().lookup(AuxiliaryConfiguration.class);
        assert aux != null;
        return aux;
    }
}
